package com.softstao.guoyu.mvp.interactor.sale;

import com.softstao.guoyu.global.APIInterface;
import com.softstao.guoyu.model.sale.ProvinceRebateCondition;
import com.softstao.guoyu.model.sale.ProvinceRebateDetails;
import com.softstao.guoyu.model.sale.RetailCondition;
import com.softstao.guoyu.model.sale.RetailDetail;
import com.softstao.guoyu.model.sale.RetailList;
import com.softstao.guoyu.model.sale.SellByYears;
import com.softstao.guoyu.model.sale.YearsManage;
import com.softstao.guoyu.mvp.interactor.BaseInteractor;
import com.softstao.guoyu.utils.MyHttpParams;

import rx.functions.Action1;

/**
 * Created by vaikus on 2017/7/19.
 */

public class RetailInteractor extends BaseInteractor {
    public void getRetailList(int page, int agentId, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId",agentId,"pageSize","4", "pageIndex",page);
        builder.setAction(action1)
                .setUrl(APIInterface.RETAIL_LIST)
                .setType(RetailList.class)
                .getVolley()
                .post(params);
    }

    public void getRetailDetail(int agentId, String retailOrderCode,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "retailOrderCode", retailOrderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.RETAIL_DETAIL)
                .setType(RetailDetail.class)
                .getVolley()
                .post(params);
    }

    public void delete(int agentId, String retailOrderCode,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "retailOrderCode", retailOrderCode);
        builder.setAction(action1)
                .setUrl(APIInterface.DEL_RETAIL)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void addRetail(RetailCondition condition,Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        builder.setAction(action1)
                .setUrl(APIInterface.ADD_RETAIL)
                .setType(null)
                .getVolley()
                .post(params);
    }

    public void getSaleByYears(int agentId, String month, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "month", month);
        builder.setAction(action1)
                .setUrl(APIInterface.SELL_BY_YEARS)
                .setType(SellByYears.class)
                .getVolley()
                .post(params);
    }

    public void getProvinceRebateDetails(int page, ProvinceRebateCondition condition, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams(condition);
        params.put("pageSize","10");
        params.put("pageIndex", page);
        builder.setAction(action1)
                .setUrl(APIInterface.PROVINCE_REBATE_DETAILS)
                .setType(ProvinceRebateDetails.class)
                .getVolley()
                .post(params);
    }

    public void getMonthManageDetails(int page, int agentId, String month, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "month", month, "pageSize","10", "pageIndex", page);
        builder.setAction(action1)
                .setUrl(APIInterface.MONTHS_REBATE_DETAILS)
                .setType(ProvinceRebateDetails.class)
                .getVolley()
                .post(params);
    }

    public void getYearsMonth(int agentId, String month, Action1<Object> action1){
        MyHttpParams params = new MyHttpParams("agentId", agentId, "month", month);
        builder.setAction(action1)
                .setUrl(APIInterface.YEARS_REBATE_DETAILS)
                .setType(YearsManage.class)
                .getVolley()
                .post(params);
    }
}
